package tk.winshu.argumentresolver.common;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import tk.winshu.argumentresolver.exception.RequestException;
import tk.winshu.argumentresolver.exception.UnLoginException;

/**
 * @author Kevin
 * @since 2019/6/10
 */
@ControllerAdvice
@Slf4j
public class GlobalExceptionAdvice {

    @ExceptionHandler(UnLoginException.class)
    public String unLoginException() {
        return "redirect:/index";
    }

    @ExceptionHandler(Exception.class)
    public String defaultException(Exception e) {
        log.error("default exception", e);
        return "default exception";
    }

    @ExceptionHandler(RequestException.class)
    public String requestException(RequestException e) {
        log.error("request exception", e);
        return "request exception";
    }
}
